﻿// Decompiled with JetBrains decompiler
// Type: StoryMode.Quests.TutorialPhase.PurchaseGrainTutorialQuest
// Assembly: StoryMode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 11BAE65F-6C15-4628-A9C6-1B968588CDA1
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\Modules\StoryMode\bin\Win64_Shipping_Client\StoryMode.dll

using StoryMode.Quests.QuestTasks;
using System;
using System.Collections.Generic;
using TaleWorlds.CampaignSystem;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

#nullable disable
namespace StoryMode.Quests.TutorialPhase
{
  public class PurchaseGrainTutorialQuest : StoryModeQuestBase
  {
    public const int BuyGrainAmount = 2;
    [SaveableField(1)]
    private readonly PurchaseItemTutorialQuestTask _purchaseItemTutorialQuestTask;

    private TextObject _buyItemTaskStartLog
    {
      get
      {
        TextObject itemTaskStartLog = new TextObject("{=D9RoNGJg}Buy 2 {GRAIN}{.s}. Click \"Buy Products\" option on village menu to buy products.");
        itemTaskStartLog.SetTextVariable("GRAIN", DefaultItems.Grain.Name);
        return itemTaskStartLog;
      }
    }

    public override TextObject Title
    {
      get
      {
        TextObject title = new TextObject("{=JhEzD45J}Purchase {GRAIN}");
        title.SetTextVariable("GRAIN", DefaultItems.Grain.Name);
        return title;
      }
    }

    public PurchaseGrainTutorialQuest(Hero questGiver)
      : base("purchase_grain_tutorial_quest", questGiver, CampaignTime.Never)
    {
      StoryMode.StoryModePhases.TutorialPhase.Instance.InitializeTutorialVillageItemRoster();
      this.SetDialogs();
      TextObject taskName = new TextObject("{=TLRyyRaW}Purchased {GRAIN} Amount");
      taskName.SetTextVariable("GRAIN", DefaultItems.Grain.Name);
      this._purchaseItemTutorialQuestTask = new PurchaseItemTutorialQuestTask(new Action(this.PurchaseItemTaskOnSuccess), 2, DefaultItems.Grain, this.AddDiscreteLog(this._buyItemTaskStartLog, taskName, 0, 2));
      this.AddTask((QuestTaskBase) this._purchaseItemTutorialQuestTask);
    }

    protected override void SetDialogs()
    {
    }

    protected override void InitializeQuestOnGameLoad()
    {
      this.SetDialogs();
      this._purchaseItemTutorialQuestTask.AddTaskBehaviorsOnGameLoad(new Action(this.PurchaseItemTaskOnSuccess));
      this._purchaseItemTutorialQuestTask.InitializeTaskOnLoad(2, DefaultItems.Grain);
    }

    protected override void HourlyTick()
    {
    }

    private void PurchaseItemTaskOnSuccess() => this.CompleteQuestWithSuccess();

    internal static void AutoGeneratedStaticCollectObjectsPurchaseGrainTutorialQuest(
      object o,
      List<object> collectedObjects)
    {
      ((MBObjectBase) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this._purchaseItemTutorialQuestTask);
    }

    internal static object AutoGeneratedGetMemberValue_purchaseItemTutorialQuestTask(object o)
    {
      return (object) ((PurchaseGrainTutorialQuest) o)._purchaseItemTutorialQuestTask;
    }
  }
}
